package com.northpool.operator.type;

import java.util.Arrays;

public enum TypeEnum {
    STRING(String.class) {

    },
    SECRET(String.class),
    NUMBER(Number.class),
    BOOL(Boolean.class),
    ENUM(String.class),
    DATASOURCE(String.class),
    DATASET(String.class),
    DB(String.class),
    ;


    final Class<?> javaType;

    TypeEnum(Class<?> javaType) {
        this.javaType = javaType;
    }

    public static TypeEnum getTypeByName(String typeName) {
        return Arrays.stream(TypeEnum.values())
                .filter(t -> t.name().equals(typeName))
                .findFirst()
                .orElseThrow(() -> new RuntimeException("定义的参数类型未找到"));
    }

}
